package produce.controller;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Kevin
 * @date 2023/6/11 12:49
 * @description 简单模式消息
 * 一对一
 **/
@RequestMapping("/simple")
@RestController
public class SimpleController {

  @Autowired
  private RabbitTemplate rabbitTemplate;

  @GetMapping
  public String send(String msg){
    CorrelationData correlationData = new CorrelationData();
    correlationData.setId("xiaohong");
    // 最后一个参数是自定义的业务数据
    rabbitTemplate.convertAndSend("","simple-queue",msg,correlationData);
    return "发送简单模式消息成功";
  }

}
